<%@page import="com.blog.dao.CategoryDao"%>
<%@page import="com.blog.dto.Replay"%>
<%@page import="com.blog.dto.Category"%>
<%@page import="com.blog.dto.Article"%>
<%@page import="java.util.Vector"%>
<%@page import="com.blog.dto.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath+"home/"%>">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>WEBLOG </title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <link rel="icon" type="image/png" href="assets/i/favicon.png">
  <meta name="mobile-web-app-capable" content="yes">
  <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileColor" content="#0e90d2">
  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  <link rel="stylesheet" href="assets/css/app.css">
  
  <style type="text/css">
  .search-submit{
	margin: 0.15rem 0.15rem;
	line-height: 2.5rem;
	border: 1px solid #eee;
	padding: 0.2rem 0.8rem 0.2rem 0.8rem;
	text-align: center;
	background: #10D07A;
	color: #F3F3F3;
  }
  .search-submit:hover{
	  background: #10D07A;
	  color: #fff;
  }
  
  </style>
</head>

<body id="blog">
<%

Vector<Article> vArticle=new Vector<Article>();
vArticle =  (Vector<Article>)session.getAttribute("allArticle");

if(vArticle==null){
	response.sendRedirect(request.getContextPath()+"/home/index?Page="+request.getParameter("Page"));
	return;
}

int m = 5;//每页要显示的行数
int Page = 1;//当前页码
int N = vArticle.size();//总数据量
int totalPage = (int)Math.ceil(N*1.0/m);
String strPage = request.getParameter("Page");
if(strPage==null || strPage.equals("")) {
	Page = 1;
}else{
	Page = Integer.parseInt(strPage);
}
 

Vector<Category> categories = new Vector<Category>();
categories = (Vector<Category>)session.getAttribute("allCategory");

Vector<Replay> vReplay = new Vector<Replay>();
vReplay=  (Vector<Replay>)session.getAttribute("allReplay");

%>
<header class="am-g am-g-fixed blog-fixed blog-text-center blog-header am-hide-sm">
    <div class="am-u-sm-8 am-u-sm-centered">
        <!-- <img width="200" src="http://s.amazeui.org/media/i/brand/amazeui.png" alt="Amaze UI Logo"/> -->
        <h1 class="am-hide-sm-only">Weblog</h1>
    </div>
</header>
<hr class="am-hide-sm">

<!-- nav start -->
<nav class="am-g am-g-fixed blog-fixed blog-nav">
<button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only blog-button" data-am-collapse="{target: '#blog-collapse'}" ><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

  <div class="am-collapse am-topbar-collapse" id="blog-collapse">
    <ul class="am-nav am-nav-pills am-topbar-nav">
      <li class="am-active"><a href="<%=request.getContextPath() %>/home/index">首页</a></li>
      
      <li><a href="<%=request.getContextPath() %>/searchServlet?act=category&keyword=科技咨讯">科技咨讯</a></li>
      <li><a href="<%=request.getContextPath() %>/searchServlet">文章分类</a></li>
      <li><a href="<%=request.getContextPath() %>/userManageServlet?act=publish">写文章</a></li>
      <li class="am-dropdown" data-am-dropdown>
     	<%
        	User user = new User();
        	user = (User)session.getAttribute("user");
        %>
        <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
          	<%=user!=null ? user.getUsername() : "登录/注册" %> <span class="am-icon-caret-down"></span>
        </a>
        
        <%
        	if(user!=null){
        %>
        <ul class="am-dropdown-content">
          <li><a href="<%=request.getContextPath() %>/userManageServlet?act=openArticle">文章管理</a></li>         
          <li><a href="<%=request.getContextPath() %>/userManageServlet?act=openTag">标签管理</a></li>
          <li><a href="<%=request.getContextPath() %>/userManageServlet?act=openReplay">评论管理</a></li>
          <li><a href="PersonalInfo.jsp">个人信息</a></li>
          <li><a href="<%=request.getContextPath()+"/userServlet?act=logout" %>">切换账户</a></li>
          <li><a href="<%=request.getContextPath()+"/userServlet?act=logout" %>">退出登录</a></li>
        </ul>
        <%	}else{    %>	
        <ul class="am-dropdown-content">
          <li><a href="login.jsp">登录</a></li>
          <li><a href="register.jsp">注册</a></li>
        </ul>
        <%  } %>
      </li>
    </ul>
   <form class="am-topbar-form am-topbar-right am-form-inline" role="search" action="<%=request.getContextPath() %>/searchServlet"  >
      <div class="am-form-group">
      	<input type="hidden"  name="act" value="searchAll">
        <input type="text" class="am-form-field am-input-sm" name="keyword" placeholder="搜索">
        <input type="submit" class="am-form-field am-input-sm search-submit" value="搜索">
      </div>
    </form>
  </div>
</nav>

<hr>
<!-- nav end -->
<!-- banner start -->
<div class="am-g am-g-fixed blog-fixed am-u-sm-centered blog-article-margin">
    <div data-am-widget="slider" class="am-slider am-slider-b1" data-am-slider='{&quot;controlNav&quot;:false}' >
    <ul class="am-slides">
    
      <li>
            <img src="assets/i/b1.jpg">
            <div class="blog-slider-desc am-slider-desc ">
                <div class="blog-text-center blog-slider-con">
                    <span><a href="" class="blog-color">Article &nbsp;</a></span>               
                    <h1 class="blog-h-margin"><a href="">总在思考一句积极的话</a></h1>
                    <p>那时候刚好下着雨，柏油路面湿冷冷的，还闪烁着青、黄、红颜色的灯火。
                    </p>
                    <span class="blog-bor">2015/10/9</span>
                    <br><br><br><br><br><br><br>                
                </div>
            </div>
      </li>
      
      
      <li>
            <img src="assets/i/b2.jpg">
            <div class="am-slider-desc blog-slider-desc">
                <div class="blog-text-center blog-slider-con">
                    <span><a href="" class="blog-color">Article &nbsp;</a></span>               
                    <h1 class="blog-h-margin"><a href="">总在思考一句积极的话</a></h1>
                    <p>那时候刚好下着雨，柏油路面湿冷冷的，还闪烁着青、黄、红颜色的灯火。
                    </p>
                    <span>2015/10/9</span>                
                </div>
            </div>
      </li>
      <li>
            <img src="assets/i/b3.jpg">
            <div class="am-slider-desc blog-slider-desc">
                <div class="blog-text-center blog-slider-con">
                    <span><a href="" class="blog-color">Article &nbsp;</a></span>               
                    <h1 class="blog-h-margin"><a href="">总在思考一句积极的话</a></h1>
                    <p>那时候刚好下着雨，柏油路面湿冷冷的，还闪烁着青、黄、红颜色的灯火。
                    </p>
                    <span>2015/10/9</span>                
                </div>
            </div>
      </li>
      <li>
            <img src="assets/i/b2.jpg">
            <div class="am-slider-desc blog-slider-desc">
                <div class="blog-text-center blog-slider-con">
                    <span><a href="" class="blog-color">Article &nbsp;</a></span>               
                    <h1 class="blog-h-margin"><a href="">总在思考一句积极的话</a></h1>
                    <p>那时候刚好下着雨，柏油路面湿冷冷的，还闪烁着青、黄、红颜色的灯火。
                    </p>
                    <span>2015/10/9</span>                
                </div>
            </div>
      </li>
    </ul>
    </div>
</div>
<!-- banner end -->

<!-- content srart -->
<div class="am-g am-g-fixed blog-fixed">
    <div class="am-u-md-8 am-u-sm-12">
	<%
		int i =0 ;
   		for(i = (Page - 1)*m ; i < (Page - 1)*m+m && i<N ; i++ ){
   			Article article = new Article();
   			article = vArticle.get(i);
   			
    %>
        <article class="am-g blog-entry-article">
            <div class="am-u-lg-6 am-u-md-12 am-u-sm-12 blog-entry-img">
            <% 
            	String image = article.getImage();
            	if(image.equals("image")) image = "assets/i/f10.jpg";
            %> 
                <img src="<%=image %>" alt="" class="am-u-sm-12">
            </div>
            <div class="am-u-lg-6 am-u-md-12 am-u-sm-12 blog-entry-text">
                <span><a href="article.jsp?article_id=<%=article.getArticle_id() %>" class="blog-color">article &nbsp;</a></span>
                <span><a href="<%=request.getContextPath() %>/searchServlet?act=author&keyword=<%=article.getAuthor() %>" style="color:#0e90d2;" > @<%=article.getAuthor() %> &nbsp;</a></span>
                <span><%=article.getPublish_time() %></span>
                <h1><a href="article.jsp?article_id=<%=article.getArticle_id() %>"><%=article.getTitle() %></a></h1>
                <p>
					<%=article.getDescription() %>
                </p>
            </div>
        </article>
     <% } %>
    
			<!-- 分页开始 -->
	  <ul data-am-widget="pagination" class="am-pagination am-pagination-default">
	
	      <li class="am-pagination-first ">
	        <a href="?Page=1" class="">首页</a>
	      </li>
	      <li class="am-pagination-prev ">
	        <a href="?Page=<%=Page==1? 1 : Page-1 %>" class="">上一页</a>
	      </li>
	      <%
	      for(i = 1 ; i<=totalPage ; i++){
	    	  if(i!=Page){
	      %>
	      <li class="">
	        <a href="?Page=<%=i %>" class=""><%=i %></a>
	      </li>
	      <%	
	      	  } else {
	      		  
	      	  
	      %>
	      <li class="am-active">
	        <a href="?Page=<%=i %>" class="am-active"><%=i %></a>
	      </li>
	      <%
	      	   }
	       }
	      %>
	      <li class="am-pagination-next ">
	        <a href="?Page=<%=Page==totalPage? totalPage : Page+1 %>" class="">下一页</a>
	      </li>
	      <li class="am-pagination-last ">
	        <a href="?Page=<%=totalPage %>" class="">尾页</a>
	      </li>
	  </ul>
			
    </div>
    
    
  <div data-am-widget="gotop" class="am-gotop am-gotop-fixed" style="right: 10%; bottom:50px; ">
    <a href="#top" title="回到顶部">
        <span class="am-gotop-title">回到顶部</span>
          <i class="am-gotop-icon am-icon-chevron-up" style="background-color: #0e90d2;"></i>
    </a>
  </div>
    

    <div class="am-u-md-4 am-u-sm-12 blog-sidebar">
        <div class="blog-sidebar-widget blog-bor am-hide-sm">
            <h2 class="blog-text-center blog-title"><span>About</span></h2>
            <img src="assets/i/f14.jpg" alt="about me" class="blog-entry-img" >
            <p>博客</p>
            <p>
&nbsp;&nbsp;&nbsp;&nbsp;博客，仅音译，英文名为Blogger,为Web Log的混成词。它的正式名称为网络日记；又音译为部落格或部落阁等，是使用特定的软件，在网络上出版、发表和张贴个人文章的人，或者是一种通常由个人管理、不定期张贴新的文章的网站。博客上的文章通常以网页形式出现，并根据张贴时间，以倒序排列。博客是继MSN.BBS.ICQ之后出现的第4种网络交流方式，现已受到大家的欢迎，是网络时代的个人“读者文摘”，是以超级链接为入口的网络日记，它代表着新的生活、工作和学习方式。许多博客专注在特定的课题上提供评论或新闻，其他则被作为个人性的日记。一个典型的博客结合了文字、图像、其他博客或网站的链接及其它与主题相关的媒体，能够让读者以互动的方式留下意见，是许多博客的重要要素。大部分的博客内容以文字为主，但仍有一些博客专注在艺术、摄影、视频、音乐、播客等各种主题。博客是社会媒体网络的一部分。比较著名的有新浪、网易等博客
        </p>
        <p>&nbsp;&nbsp;&nbsp;&nbsp;一个Blog其实就是一个网页，它通常是由简短且经常更新的帖子所构成，这些张贴的文章都按照年份和日期倒序排列。</p>
        </div>
        <div class="blog-sidebar-widget blog-bor">
            <h2 class="blog-text-center blog-title"><span>Contact ME</span></h2>
            <p>
                <a href=""><span class="am-icon-qq am-icon-fw am-primary blog-icon"></span></a>
                <a href=""><span class="am-icon-github am-icon-fw blog-icon"></span></a>
                <a href=""><span class="am-icon-weibo am-icon-fw blog-icon"></span></a>
                <a href=""><span class="am-icon-reddit am-icon-fw blog-icon"></span></a>
                <a href=""><span class="am-icon-weixin am-icon-fw blog-icon"></span></a>
            </p>
        </div>
        <div class="blog-clear-margin blog-sidebar-widget blog-bor am-g ">
            <h2 class="blog-title"><span>Category cloud</span></h2>
            <div class="am-u-sm-12 blog-clear-padding">
            <%
            	CategoryDao categoryDao = new CategoryDao();
            	Vector<Category> vCategories = new  Vector<Category>();
            	vCategories = categoryDao.findAllCategory();
            	for(Category cate : vCategories){
            %>
	            <a href="<%=request.getContextPath() %>/searchServlet?act=category&keyword=<%=cate.getCategory() %>" class="blog-tag"><%=cate.getCategory() %></a>
	        <%	} %>
	            
            </div>
        </div>
    </div>
</div>
<!-- content end -->



  <footer class="blog-footer">
    <div class="am-g am-g-fixed blog-fixed am-u-sm-centered blog-footer-padding">
        <div class="am-u-sm-12 am-u-md-4- am-u-lg-6 am-text-center">
            <h2>网站简介</h2>
            <p class="am-text-sm am-text-left text-indent2" style="text-indent:2em; ">
            	该博客管理系统开发的总体目标为实现的方便、高效、快捷的搭建个人博客，方便大家对个人博客的使用和方便管理员对个人博客的管理，从而促进大家网络的交流。
            	
            </p>
            <p class="am-text-sm am-text-left text-indent2" style="text-indent:2em; ">
            	本网站是用来amaze UI开发前端页面，系统中还使用了UEditor富文本编辑器，实现了类似word文档的样式编辑功能和图片插入。
            </p>
            
            
            <!-- &nbsp;&nbsp;&nbsp;&nbsp; -->
        </div>
        
        <div class="am-u-sm-12 am-u-md-4- am-u-lg-6 am-text-center">
             <h2 class="am-center">我们站在巨人的肩膀上</h2>
            
            <p>
                <ul class="am-text-left">
                    <li class="am-u-sm-4"><a href="https://www.runoob.com/jquery/jquery-tutorial.html" target="_blank">jQuery</a></li>
                    <li class="am-u-sm-4"><a href="https://www.html.cn/doc/zeptojs_api/" target="_blank">Zepto.js</a></li>
                    <li class="am-u-sm-4"><a href="http://amazeui.org/css/utility" target="_blank">amaze UI</a></li>
                    <li class="am-u-sm-4"><a href="https://ueditor.baidu.com/website/" target="_blank">UEditor</a></li>
                    <li class="am-u-sm-4"><a href="https://www.layui.com/" target="_blank">layui</a></li>
                    <li class="am-u-sm-4"><a href="http://www.h-ui.net/H-ui.admin.shtml" target="_blank">h-ui</a></li>
                    <li class="am-u-sm-4"><a href="https://www.runoob.com/mysql/mysql-tutorial.html" target="_blank">MySQL</a></li>
                    <li class="am-u-sm-4"><a href="https://easy-mock.com/login" target="_blank">easy mock</a></li>
                    <li class="am-u-sm-4"><a href="" target="_blank">...</a></li>
                </ul>
            </p>
        </div>
    </div>    
    <div class="blog-text-center">© 2015 Weblog , Inc. Licensed under MIT license. Made with love By LWXYFER</div>    
  </footer>





<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
</body>
</html>